/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hanuma;

import java.util.*;
import com.google.gson.*;

/**
 *
 * @author niyaz
 */
public class Person {
    public String asString = null;
    public String ID;
    public String name;
    public List<String> groups = new LinkedList<String>();
    public List<String> friends = new LinkedList<String>();
    public List<String> albums = new LinkedList<String>();
    public List<WallRecord> wall;
    public int numberOfFotos;
    public List<String> music = new LinkedList<String>();
    public List<String> video = new LinkedList<String>();
    public List<String> notes = new LinkedList<String>();
    public List<String> univers = new LinkedList<String>();


    public void cleanBeforeSerilazation(){
        asString = null;
    }
    
/*    public void makeSureDeserilezed() throws Exception{
        if (ID == null){
            if (asString == null){
                throw new Exception("problems with deser");
            }
            Gson gson = new Gson();
            Person p =  (Person) gson.fromJson(asString, this.getClass());
            this.ID = p.ID;
            this.albums = p.albums;
            this.friends = p.friends;
            this.groups = p.groups;
            this.music = p.music;
            this.name = p.name;
            this.notes = p.notes;
            this.numberOfFotos = p.numberOfFotos;
            this.video = p.video;
            this.wall = p.wall;
        }
    }
*/

   public String toString(){
       if (asString != null) {
           return asString;
       }
        String buf = ID;
        buf += " "+name;
        buf += " "+this.numberOfFotos;

        for (String str : groups){
            buf+=" "+str;
        }

        for (String str : albums){
            buf+=" "+str;
        }

        for (String str : friends){
            buf+=" "+str;
        }

        for (WallRecord rec : wall){
            buf +=" "+ rec.text;
        }

        for (String str : music){
            buf+=" "+str;
        }

        for (String str : video){
            buf+=" "+str;
        }

        for (String str : notes){
            buf+=" "+str;
        }
        asString = buf.toLowerCase();
        return asString;
   }

}
